package com.wubotao.algorithm;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Selection {
	
	public static <E extends Comparable<? super E>> void sort(List<E> list) {
		for (int index = 0; index < list.size() - 1; index++) {
			int min = index;
			for (int time = index + 1; time < list.size(); time++) {
				if (list.get(time).compareTo(list.get(min)) < 0) {
					min = time;
				}
			}
			Collections.swap(list, index, min); 			
		}
	}
	
	public static void main(String[] args) {
		List<Integer> list = Arrays.asList(5, 69, 12, 3, 56, 789, 2, 5648, 23);
		sort(list);
		System.out.println(list);
	}
}

